Skip to content

Fix null-ref crash in CLRMA when querying nested exceptions on message-only fail-fast#5889

Merged
hoyosjs merged 3 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/crashinfo-message-only-failfast
Jun 19, 2026
Merged

Fix null-ref crash in CLRMA when querying nested exceptions on message-only fail-fast#5889
hoyosjs merged 3 commits into
dotnet:mainfrom
hoyosjs:juhoyosa/crashinfo-message-only-failfast

Conversation

@hoyosjs

@hoyosjs hoyosjs commented Jun 18, 2026

Copy link
Copy Markdown
Member

The runtime emit a triage JSON with no "exception" block when
Environment.FailFast() is called without an exception (e.g. a garbage-
collected delegate). CrashInfoService parsed this correctly but left
_exception null, which caused a null-ref crash downstream in CLRMA when iterating nested exceptions.

Adds a regression test covering the Delegate_GarbageCollected payload seen in a dump

…e-only fail-fast

The runtime emit a triage JSON with no "exception" block when
 Environment.FailFast() is called without an exception (e.g. a garbage-
 collected delegate). CrashInfoService parsed this correctly but left
 _exception null, which caused a null-ref crash downstream in CLRMA when iterating nested exceptions.

Adds a regression test covering the Delegate_GarbageCollected payload seen in a dump
Copilot AI review requested due to automatic review settings June 18, 2026 04:54
@hoyosjs hoyosjs requested a review from a team as a code owner June 18, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a null-reference crash in CLRMA when processing NativeAOT triage JSON produced by Environment.FailFast() without an exception block (message-only fail-fast). The change makes nested-exception enumeration resilient to missing crash exceptions and adds a regression unit test for the observed Delegate_GarbageCollected payload.

Changes:

  • Update CrashInfoService.GetNestedExceptions to return an empty sequence when no crash exception exists, and to tolerate null inner-exception collections/elements.
  • Add a defensive guard in CLRMA ThreadWrapper to avoid constructing nested exception wrappers when the thread exception is absent.
  • Add a unit test covering message-only NativeAOT crash info parsing and nested-exception querying.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/CrashInfoServiceTests.cs Adds regression test for message-only NativeAOT triage JSON (no exception block).
src/SOS/SOS.Extensions/Clrma/ThreadWrapper.cs Avoids nested-exception wrapping when there is no thread exception (prevents CLRMA null-ref path).
src/Microsoft.Diagnostics.DebugServices.Implementation/CrashInfoService.cs Returns empty nested-exception enumeration when _exception is missing and hardens recursive enumeration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/CrashInfoServiceTests.cs Outdated
@steveisok

Copy link
Copy Markdown
Member

Suggestions seem reasonable. Otherwise looks good

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@hoyosjs hoyosjs enabled auto-merge (squash) June 19, 2026 11:22
@hoyosjs hoyosjs merged commit edba659 into dotnet:main Jun 19, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants